﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace EventMonitor.Windows
{
	/// <summary>
	/// Interaction logic for OptionsWindow.xaml
	/// </summary>
	public partial class OptionsWindow : Window
	{
		public OptionsWindow()
		{
			InitializeComponent();
		}

		protected override void OnInitialized(EventArgs e)
		{
			base.OnInitialized(e);

			int recordCount = ((EventMonitor.App)Application.Current).ResultFilterRecordCount;
			if (recordCount > 0)
				this.ResultsFilterBox.Text = recordCount.ToString();
		}

		private void OKButton_Click(object sender, RoutedEventArgs e)
		{
			object value = this.ResultsFilterBox.Text;
			int recordCount = -1;

			if (value != null && !DBNull.Value.Equals(value))
				recordCount = Convert.ToInt32(value);

			((EventMonitor.App)Application.Current).ResultFilterRecordCount = recordCount;
			this.Close();
		}

		private void CancelButton_Click(object sender, RoutedEventArgs e)
		{
			this.Close();
		}
	}
}
